package com.tzvtc.server.commons.exception;

import com.tzvtc.server.commons.bean.ResultBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionAdvice {

    @ExceptionHandler(NormalException.class)
    public ResultBean handleNormalException(NormalException e){
        log.info("NormalException异常: {}", e.getMessage());
        return ResultBean.fail(e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public ResultBean handleRuntimeException(Exception e) {
        log.info("系统错误信息为: {}", e.getMessage());
        return ResultBean.fail("系统错误");
    }



}
